package net.dfx.iot_download_tool.vo;

import java.time.Instant;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;

/**
 * 从用户输入的2025-08-14 00:00:01时间对读取到VO，并且格式化成本地时区
 */
public class LocalSETimeVO {
	
	public LocalSETimeVO() {
		super();
	}
	public LocalSETimeVO(ZonedDateTime startT, ZonedDateTime endT) {
		super();
		this.startT = startT;
		this.endT = endT;
		this.dateStr = "";
	}
	public LocalSETimeVO(ZonedDateTime startT, ZonedDateTime endT, String dateStr) {
		super();
		this.startT = startT;
		this.endT = endT;
		this.dateStr = dateStr;
	}
	private ZonedDateTime startT;
    private ZonedDateTime endT;
    private String dateStr;
	public ZonedDateTime getStartT() {
		return startT;
	}
	public void setStartT(ZonedDateTime startT) {
		this.startT = startT;
	}
	public ZonedDateTime getEndT() {
		return endT;
	}
	public void setEndT(ZonedDateTime endT) {
		this.endT = endT;
	}
	public String getDateStr() {
		return dateStr;
	}
	public void setDateStr(String dateStr) {
		this.dateStr = dateStr;
	}
	/**
	 * 获取开始时间的时间戳，精确到秒
	 * @return long 时间戳数字
	 */
	public long getStartSec() {
		Instant intst = this.startT.toInstant();
		return intst.getEpochSecond();
	}
	/**
	 * 获取结束时间的时间戳，精确到秒
	 * @return long 时间戳数字
	 */
	public long getEndSec() {
		Instant intst = this.endT.toInstant();
		return intst.getEpochSecond();
	}
	/**
	 * 获取开始时间和终止时间时间差，单位为天
	 * @return long 类型值
	 */
	public long getDateNum() {
		long totalSec = ChronoUnit.SECONDS.between(startT, endT);
		long absTotalSec = Math.abs(totalSec);
		long dayAbs = absTotalSec/86400;
		if (absTotalSec%86400 != 0) {
			dayAbs++;
		}
		return dayAbs;
	}
}
